//
//  JokeTableViewCell.m
//  MansApp
//
//  Created by lanou3g on 15/7/14.
//  Copyright (c) 2015年 ACH. All rights reserved.
//

#import "JokeTableViewCell.h"

@implementation JokeTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backImageView = [[UIImageView alloc]initWithFrame:CGRectMake(kP6Height(10), kP6Height(10), kWidth - kP6Height(20), kP6Height(100))];
        self.backImageView.image = [UIImage imageNamed:@"bg_share_large@2x.png"];
        [self.contentView addSubview:_backImageView];
        
        self.contentView.backgroundColor = [UIColor colorWithRed:0.616 green:0.615 blue:0.664 alpha:0.300];
        
        self.jokeLable = [[UILabel alloc]initWithFrame:CGRectMake(kP6Height(10), kP6Height(10),self.backImageView.frame.size.width - kP6Height(20),kP6Height(80))];
        [self.backImageView addSubview:_jokeLable];
        
    }
    return self;
}

- (void)cellSetModel:(JokeModel *)model
{
    CGRect bounds = [model.content boundingRectWithSize:CGSizeMake(300, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:14] forKey:NSFontAttributeName] context:nil];
    self.jokeLable.text = model.content;
    self.jokeLable.textColor = [UIColor colorWithRed:0.213 green:0.153 blue:0.519 alpha:1.000];
    self.jokeLable.font = [UIFont fontWithName:@"Courier-BoldOblique" size:15];
    self.jokeLable.numberOfLines = 0;
    self.jokeLable.frame = CGRectMake(kP6Height(10), kP6Height(10),self.backImageView.frame.size.width - kP6Height(20),bounds.size.height);
    self.backImageView.frame = CGRectMake(kP6Height(10), kP6Height(10),kWidth - kP6Height(20),bounds.size.height + kP6Height(20));
}

// 动态计算cell高度
+ (CGFloat)heightForCell:(JokeModel *)model
{
    CGRect bounds = [model.content boundingRectWithSize:CGSizeMake(300, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:14] forKey:NSFontAttributeName] context:nil];
    return bounds.size.height + kP6Height(25);
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
